package com.zlzxm.shoesmarket.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.zlzxm.shoesmarket.TestConstant;
import com.zlzxm.shoesmarket.util.RxAndroidHelp;
import com.zlzxm.shoesmarket.viewmodel.entity.EntityAccount;

import java.util.concurrent.TimeUnit;

import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;

/**
 * CREATE BY zlzxm ON 4/13/21
 */
public class VMAccount extends ViewModel {

    public static final MutableLiveData<EntityAccount> liveAccount = new MutableLiveData<>();

    public  MutableLiveData<EntityAccount> getLiveAccount() {
        return liveAccount;
    }

    public void requestAccount(){

        Observable.timer(3, TimeUnit.SECONDS)
                .compose(RxAndroidHelp.turn())
                .subscribe(new Observer<Long>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull Long aLong) {

                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                        liveAccount.setValue(createTest());

                    }
                });


    }


    //<editor-fold defaultState="collapsed" desc="测试">


    public EntityAccount createTest(){

        EntityAccount entityAccount = new EntityAccount();
        entityAccount.setFace(TestConstant.PIC_EIGHT);
        entityAccount.setNick("大帅哥");
        entityAccount.setPhone("15757808573");
        entityAccount.setBindWx(true);



        return entityAccount;

    }



    // </editor-fold>



}
